﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Threading.Tasks;
using FinPlusCommon;
using log = Logger.Logger;
using u = FinPlusUtility.Utility;

namespace FinPlusComponents
{
    public class FinPlusLink : FinPlusComponent
    {
        public override IFunctions Adaptor { get { return _adaptor.Adaptor; } }
        public override string TestString { get { return Adaptor.ToString(); } }

        private readonly IList<IFinPlusComp> _links;
        private readonly IFinPlusComp _adaptor;

        //construct
        public FinPlusLink(IFinPlusComp[] links, IFinPlusComp modelLink)
        {
            _adaptor = modelLink;
            _links = new List<IFinPlusComp>();
            IsValid = true;
        }

        //common control interface
        public override void Dispose()
        {
            if (_adaptor != null)
                _adaptor.Dispose();

            foreach (var link in _links)
                if (link != null)
                    link.Dispose();
        }
    }
}
       